﻿@{
    ViewBag.Title = "坐标地址标注";
}
@section HeaderContent{
    <script type="text/javascript" charset="utf-8" src="http://api.map.baidu.com/api?v=2.0&ak=0Rg88PISLHEhyvn6syEzlmGT"></script>
    <script type="text/javascript" charset="utf-8" src="http://api.map.baidu.com/library/MarkerTool/1.2/src/MarkerTool_min.js"></script>
    <script type="text/javascript" charset="utf-8" src="http://api.map.baidu.com/library/CityList/1.4/src/CityList_min.js"></script>
    <style type="text/css">
        .content{position:relative;width:550px;height:350px}
        #f_container{border:1px solid #999;position:absolute;top:10px;left:10px;z-index:1000;font-size:14px}
        #container{width:290px;overflow:hidden;height:20px;background:#f2f3f5;border:5px solid #f2f3f5}
        #container select{border:1px solid #ccc;font-size:14px}
    </style>
    <script type="text/javascript">
        var api = parent.layer.getFrameIndex(window.name); //获取父窗体对象
        function mapHtml(data) {
            $(data).parents("body").find("#txtXPoint").val($("#lat").val());
            $(data).parents("body").find("#txtYPoint").val($("#lng").val());
        }
    </script>
}
<div class="content">
    <div id="f_container">
        <div id="container"></div>
    </div>
    <div id="allmap" style="width:550px;height:350px;"></div>
    <input type="hidden" id="lat" />
    <input type="hidden" id="lng" />
</div>
@section Scripts{
    <script type="text/javascript">
        // 百度地图API功能
        var map = new BMap.Map("allmap");            // 创建Map实例
        map.enableScrollWheelZoom(true);
        map.addControl(new BMap.ScaleControl({ anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));    // 右下比例尺
        map.setDefaultCursor("Crosshair"); //鼠标样式
        map.addControl(new BMap.NavigationControl({ anchor: BMAP_ANCHOR_TOP_RIGHT }));  //右上角，仅包含平移和缩放按钮
        var cityList = new BMapLib.CityList({
            container: 'container',
            map: map
        });
        map.addEventListener("click", showInfo);
        function showInfo(e) {
            map.clearOverlays();
            marker = new BMap.Marker(new BMap.Point(e.point.lng, e.point.lat));  // 创建标注
            map.addOverlay(marker);
            //获取经纬度
            document.getElementById("lng").value = e.point.lng;
            document.getElementById("lat").value = e.point.lat;
        }
    </script>
}
